﻿using System;
using System.Drawing;
using System.Windows.Forms;
using EnsembleGame.Properties;
using Ensemble_Windows.Game;
using Ensemble_Windows.UI.Button;
using Ensemble_Windows.UI.Panel;
using Button = Ensemble_Windows.UI.Button.Button;
using Panel = Ensemble_Windows.UI.Panel.Panel;

namespace EnsembleGame.Form
{
    /// <summary>
    ///     登录界面
    /// </summary>
    public class Login
    {
        /// <summary>
        ///     构造函数
        /// </summary>
        /// <param name="service">游戏服务</param>
        public Login(IService service)
        {
            Service = service;
            LoginPanel = PanelHelper.Create();
            //创建一个窗口(宽,高,位置(x.y),载体)
            LoginPanel = PanelHelper.Create(0, 0, new Point(100, 100), service.Form);
            //放大到载体大小           
            LoginPanel.Dock = DockStyle.Fill;
            //设置窗口背景图  
            LoginPanel.BackgroundImage = Image.FromFile(@"Resource\ui1.jpg");

            //创建一个按钮
            StartButton = ButtonHelper.Create();
            //按钮加入窗口
            LoginPanel.Controls.Add(StartButton);
            //按钮位置设置
            var x = StartButton.Width / 2;
            StartButton.Location = new Point(400 + x, 500);
            //改变按钮名称
            StartButton.Text = Resources.MainGame_Initialize_StartGame;
            //被单机单机事件
            StartButton.Click += StartButton_Click;
        }

        private Panel LoginPanel { get; set; }
        private Button StartButton { get; set; }

        /// <summary>
        ///     游戏服务
        /// </summary>
        public IService Service { get; set; }


        private void StartButton_Click(object sender, EventArgs e)
        {
            LoginPanel.Hide();
            // ReSharper disable once ObjectCreationAsStatement
            new ModSelect(Service);
        }
    }
}